
from xml.etree.ElementTree import Element,parse

doc = parse('pre.xml')
root = doc.getroot()
print(root)

root.remove(root.find("item"))

# for line in root.getchildren():
#     for item in line.getchildren():
#         print(item.text)


e = Element("spam")
e.text = 'this is a test'

root.insert(2,e)

doc.write('newpred.xml',xml_declaration=True)

